package com.user.dao;

import com.user.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * mapper
 */
@Mapper
@Repository
public interface UserMapper {
    /**
     * 列表
     * @param user
     * @return
     */
    List<User> selects(@Param("user") User user);

    /**
     * 注册
     * @param user
     * @return
     */
    @Insert("insert into w_users set username=#{user.username},pwd=#{user.pwd},name=#{user.name},sex=#{user.sex},dq=#{user.dq},tel=#{user.tel},email=#{user.email}")
    int insert(@Param("user") User user);

    int update(@Param("user")User user);

    /**
     * 删除
     * @param ids
     * @return
     */
    @Delete("delete from w_users where id in(${ids})")
    int del(@Param("ids")String ids);

    /**
     * 登录
     * @param user
     * @return
     */
    @Select("select * from w_users where username=#{user.username} and pwd=#{user.pwd}")
    User login(@Param("user")User user);
}
